import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DistrictVO, DistrictForm, DistrictQuery } from '@/api/kitchen/area/district/types';

/**
 * 查询区县列表
 * @param query
 * @returns {*}
 */

export const listDistrict = (query?: DistrictQuery): AxiosPromise<DistrictVO[]> => {
  return request({
    url: '/kitchen/district/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询区县详细
 * @param id
 */
export const getDistrict = (id: string | number): AxiosPromise<DistrictVO> => {
  return request({
    url: '/kitchen/district/' + id,
    method: 'get'
  });
};

/**
 * 新增区县
 * @param data
 */
export const addDistrict = (data: DistrictForm) => {
  return request({
    url: '/kitchen/district',
    method: 'post',
    data: data
  });
};

/**
 * 修改区县
 * @param data
 */
export const updateDistrict = (data: DistrictForm) => {
  return request({
    url: '/kitchen/district',
    method: 'put',
    data: data
  });
};

/**
 * 删除区县
 * @param id
 */
export const delDistrict = (id: string | number | Array<string | number>) => {
  return request({
    url: '/kitchen/district/' + id,
    method: 'delete'
  });
};
